package practice.project;

public class Student extends Thread{
    /*
          创建People对象的变量：
            变量类型一定要与要定义为变量的类的类名一样（）
     */

    private People people; //该变量用于接收People类创建对象的地址，所以变量类型要和类名一样

    public Student(People people) { //接收传递过来的People类的地址，也就是People p = new  People();将这个p传过来
        this.people = people;       //那么这个people就是一个对象了
    }

    @Override
    public void run() {

        synchronized(people){  //这里people对象就可作为对象锁
            try {
                people.wait(); //
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
